<template>
    <div>
        授权中 --{{ code }}
    </div>
</template>
<script setup>
import axios from 'axios'
import { useRoute, useRouter } from 'vue-router';

const route = useRoute()
const router = useRouter()

const code = route.query.code

console.log(code);

const _get_message = () => {
    axios.post('https://gitee.com/oauth/token', {
        grant_type: 'authorization_code',
        code: code,
        client_id: '4864241bd37be4d8ac350f602f04d41c9a6f67fe197e3a1bbca6dbacdd6df555',
        redirect_uri: 'http://localhost:5173/oauth/lzd',
        client_secret: '1f83d67b192208a02072271b6f29ee61b47601dda96935b6a4415d8f05425c7e'
    }).then(res => {
        console.log(res);
        if (res.status === 200) {
            localStorage.setItem('access_token', res.data.access_token)
            localStorage.setItem('refresh_token', res.data.refresh_token)
            router.push({
                path: '/'
            })
        }
    })
}
_get_message()
</script>